<script src="../js/equal.js"></script>
<script>
  // 1
  {
    const middle = [1, 2, 3];
    const arr = [0, middle, 4];
    console.assert((arr, [0, 1, 2, 3, 4]), `1. 不成立`);
  }
  // 2  x
  {
    const arr = [0, 1];
    console.assert(equal(arr, [0, 1]), `2. 不成立`);
  }
  // 3
  {
    const [...rest] = [...[1, 2, 3, 4, 5]];
    console.assert(equal(rest, [1, 2, 3, 4, 5]), `3. 不成立`);
  }

  // 4
  {
    const [a, [b, ,], ...rest] = [1, [2, 3], 4, 5];
    assert.equal(a, 1);
    assert.equal(b, 2);
    console.assert(equal(rest, [3, 4, 5]), `4. 不成立`);
  }
  // 5
  {
    const magicNumbers = [1, 2];
    const fn = ([magicA, magicB]) => {
      console.assert(equal(magicA, magicNumbers[0]), `5-1. 不成立`);
      console.assert(equal(magicB, magicNumbers[1]), `5-2. 不成立`);
    };
    fn(magicNumbers);
  }
  // 6
  {
    const max = Math.max(...[23, 0, 42, 42]);
    console.assert(max === 42, `6. 不成立`);
  }
  // 7
  {
    class X {
      constructor(a, b = 2, c = 3) {
        return [a, b, c];
      }
    }
    const args = [1];
    console.assert(equal(new X(...args), [1, 2, 3]), `7. 不成立`);
</script>
